﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
public partial class aspnet_admin_bock_Column_CX_Column_Show : System.Web.UI.Page
{
    public TongUse TextData = new TongUse();
    public string MenuListText;

    public string actions = "";

    string UrlQuery = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        UrlQuery ="&"+ TextData.UrlData;
        
        try
        {
            actions = Request.QueryString["action"].ToString();
        }
        catch
        {
            actions = "";
        }

        if (!IsPostBack)
        {

            MenuListText = ShowTree(0, actions);//显示网站菜单
        }

        Page.Title = "显示栏目";

    }

    /// <summary>
    /// SelectXML 方法要输出的XML文本文件
    /// </summary>
    string TreeXmlText = "";
    int ii = 0;
    /// <summary>
    /// 返回菜单显示的HTML代码
    /// </summary>
    /// <param name="select">显示的展次</param>
    /// <returns></returns>
    public String ShowTree(int select,string action)
    {
        string sql;
        int i = 0;
        DataTable MyDt = new DataTable();
        sql = "Select * From CX_Column where CX_Column_LX<>3 and CX_Column_followid =" + select + " order by CX_Column_id desc";
        try
        {

            MyDt = TextData.SqlataSet(sql).Tables[0];//创建DataTable MyDt
        }
        catch (Exception ex)
        {
            TextData.Err(ex.Message);

        }
        for (i = 0; i < MyDt.Rows.Count; i++)//遁环记录集
        {

            if (action == "show")//查看栏目
            {

                if (select == 0)//如果只一有层的话
                {

                    TreeXmlText += "<tr >\r  <td width='223' class='tdbg' style='height: 27px' onmouseover=\"this.className ='';\" onmouseout=\"this.className='tdbg'\">\r" +

                         "  " +

                          "     <input type=\"checkbox\" name=\"ClomnID\" value=\"" + MyDt.Rows[i]["CX_Column_id"].ToString() + "\" />选择 </a> | \r" +
                          " </td>\r" +
                      " <td width='787' class='tdbg' style='height: 27px'>\r" +

                         MyDt.Rows[i]["CX_Column_Name"].ToString() +
                      " </td>\r" +
                    "</tr>\r";
                }
                else
                {
                    TreeXmlText += "<tr>\r  <td width='223' class='tdbg' style='height: 27px' onmouseover=\"this.className ='';\" onmouseout=\"this.className='tdbg'\" >\r" +

                                                "  " +

                          "      <input type=\"checkbox\" name=\"ClomnID\" value=\"" + MyDt.Rows[i]["CX_Column_id"].ToString() + "\" />选择 </a> | \r" +

                           "    <a href='CX_Column_Del.ashx?id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + "' class='link1'><!--删除栏目--></a> \r" +
                            " </td>\r" +
                        " <td width='787' class='tdbg' style='height: 27px'>\r" +

                         TextData.EStr(ii, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") + MyDt.Rows[i]["CX_Column_Name"].ToString() +
                       " </td>\r" +
                    "</tr>\r";
                }
            }
            else
            {
                if (action == "all")//可以删除
                {
                    if (select == 0)//如果只一有层的话
                    {

                        TreeXmlText += "<tr>\r  <td width='223' class='tdbg' style='height: 27px' onmouseover=\"this.className ='';\" onmouseout=\"this.className='tdbg'\">\r" +

                             "  <a href='CX_Column_AddNew.aspx?action=Add&id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "' class='link1'>建立子栏目</a> |\r" +

                              "     <a href='CX_Column_Edit.aspx?action=Edit&id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "' class='link1'>编辑栏目</a> | &nbsp;&nbsp;&nbsp;\r" +

                               "    <a href=\"javascript:Del('CX_Column_Del.ashx?id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "','此功能请审重\\r\\n删除栏目操作 将删除 栏目名，此栏目下添加的的有数据，包括新闻分类，添加的所有新闻\\r\\n" + MyDt.Rows[i]["CX_Column_Name"].ToString() + "')\" class='link1' > 删除栏目</a> \r" +
                              " </td>\r" +
                          " <td width='787' class='tdbg' style='height: 27px'>\r" +

                             MyDt.Rows[i]["CX_Column_Name"].ToString() +
                          " </td>\r" +
                        "</tr>\r";
                    }
                    else
                    {
                        TreeXmlText += "<tr>\r  <td width='223' class='tdbg' style='height: 27px' onmouseover=\"this.className ='';\" onmouseout=\"this.className='tdbg'\">\r" +

                                                    "  <a href='CX_Column_AddNew.aspx?action=Add&id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "' class='link1'>建立子栏目</a> |\r" +

                              "     <a href='CX_Column_Edit.aspx?action=Edit&id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "' class='link1'>编辑栏目</a> | &nbsp;&nbsp;&nbsp;\r" +

                               "    <a href=\"javascript:Del('CX_Column_Del.ashx?id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "','此功能请审重\\r\\n删除栏目操作 将删除 栏目名，此栏目下添加的的有数据，包括新闻分类，添加的所有新闻\\r\\n" + MyDt.Rows[i]["CX_Column_Name"].ToString() + "')\" class='link1'> 删除栏目</a> \r" +
                                " </td>\r" +
                            " <td width='787' class='tdbg' style='height: 27px'>\r" +

                             TextData.EStr(ii, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") + MyDt.Rows[i]["CX_Column_Name"].ToString() +
                           " </td>\r" +
                        "</tr>\r";
                    }
                }
                else
                {
                    if (select == 0)//如果只一有层的话
                    {

                        TreeXmlText += "<tr>\r  <td width='223' class='tdbg' style='height: 27px' onmouseover=\"this.className ='';\" onmouseout=\"this.className='tdbg'\">\r" +

                             "  <a href='CX_Column_AddNew.aspx?action=Add&id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "' class='link1'>建立子栏目</a> |\r" +

                              "     <a href='CX_Column_Edit.aspx?action=Edit&id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "' class='link1'>编辑栏目</a> | &nbsp;&nbsp;&nbsp;\r" +

                               "    <a href=\"javascript:Del('CX_Column_Del.ashx?id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "','此功能请审重\\r\\n删除栏目操作 将删除 栏目名，此栏目下添加的的有数据，包括新闻分类，添加的所有新闻\\r\\n" + MyDt.Rows[i]["CX_Column_Name"].ToString() + "')\" class='link1' ><!--删除栏目--></a> \r" +
                              " </td>\r" +
                          " <td width='787' class='tdbg' style='height: 27px'>\r" +

                             MyDt.Rows[i]["CX_Column_Name"].ToString() +
                          " </td>\r" +
                        "</tr>\r";
                    }
                    else//不能删除没有删除的权限
                    {
                        TreeXmlText += "<tr>\r  <td width='223' class='tdbg' style='height: 27px' onmouseover=\"this.className ='';\" onmouseout=\"this.className='tdbg'\">\r" +

                                                    "  <a href='CX_Column_AddNew.aspx?action=Add&id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "' class='link1'>建立子栏目</a> |\r" +

                              "     <a href='CX_Column_Edit.aspx?action=Edit&id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "' class='link1'>编辑栏目</a> | &nbsp;&nbsp;&nbsp;\r" +

                               "    <a href=\"javascript:Del('CX_Column_Del.ashx?id=" + MyDt.Rows[i]["CX_Column_id"].ToString() + UrlQuery + "','此功能请审重\\r\\n删除栏目操作 将删除 栏目名，此栏目下添加的的有数据，包括新闻分类，添加的所有新闻\\r\\n" + MyDt.Rows[i]["CX_Column_Name"].ToString() + "')\" class='link1'><!--删除栏目--></a> \r" +
                                " </td>\r" +
                            " <td width='787' class='tdbg' style='height: 27px'>\r" +

                             TextData.EStr(ii, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") + MyDt.Rows[i]["CX_Column_Name"].ToString() +
                           " </td>\r" +
                        "</tr>\r";
                    }
                }
            }
                ii = ii + 1;
                ShowTree(int.Parse(MyDt.Rows[i]["CX_Column_id"].ToString()), action);//调用自己显示菜单ＨＴＭＬ
                ii -= 1;
            
        }


        return TreeXmlText;
    }
}
